#ifndef SIMPLEPLUGIN_H
#define SIMPLEPLUGIN_H

#include <QObject>
#include <QString>
#include <QStringList>
#include <QFile>
#include <QPair>
#include <QList>
#include <QPushButton>
#include <QNetworkAccessManager>
#include <QNetworkReply>

#include "dictionaryinterface.h"

#include "json.h"

using QtJson::JsonObject;
using QtJson::JsonArray;

class QQDict : public QObject, DictionaryInterface
{
    Q_OBJECT
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    Q_PLUGIN_METADATA(IID "Abhidhaana.Plugin.DictionaryInterface/1.0" FILE "qqdict.json")
#endif
    Q_INTERFACES(DictionaryInterface)

public:
    QQDict();
    ~QQDict();
//necessary APIs
    DictionaryDescription getDescription();
    void queryWord(QString key);
    QList<QPair<QString, QString> > getCandidateWords(QString key);

signals:
    void filterChanged();
    void readyToShow(QString);

private:

    QNetworkAccessManager qnam;
    QNetworkReply *reply;
    QString parseJson(QString jsoncontent);
private slots:
    void httpFinished();
};

#endif // SIMPLEPLUGIN_H
